#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main(int argc, char const *argv[])
{
    if (argc != 2)
    {
        printf("请输入域名\n");
        return 0;
    }

    struct hostent *host = gethostbyname(argv[1]);
    if (host == NULL)
    {
        printf("域名解析失败\n");
        return 0;
    }

    for(int i = 0; host->h_addr_list[i] != NULL; i++)
    {
        printf("%s\n", inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));
    }
    return 0;
}
